<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // 所谓 拷贝 - 复制
        // 浅拷贝 - 只拷贝一层
        // 复制数组
        // let arr = [1, 2, [4, 5, 6], 4];

        // let arr2 = [...arr];

        // console.log(arr === arr2);

        // arr2[2][0] = 888;

        // arr2[0] = '老王';

        // console.log(arr[2] === arr2[2]);

        // console.log(arr);
        // console.log(arr2);

        // 复制对象
        let obj = {
            name: "老王",
            age: 18,
            like: ["篮球", "足球", "乒乓球"]
        }

        let obj2 = {...obj
        };

        obj2['like'][0] = '羽毛球';

        console.log(obj);
        console.log(obj2);
    </script>
</body>

</html>